package com.KKd.controller;

import com.KKd.pojo.Catalogue;
import com.KKd.pojo.Chain;
import com.KKd.pojo.Diary;
import com.KKd.service.CatalogueServiceImpl;
import com.KKd.service.ChainServiceImpl;
import com.KKd.service.DiaryServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.jws.WebParam;
import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @author 14587
 * @date 2020/11/14 16:45
 */
@RequestMapping("/page")
@Controller
public class PageController {
    @Autowired
    private DiaryServiceImpl diaryService;
    @Autowired
    private ChainServiceImpl chainService;
    @Autowired
    private CatalogueServiceImpl catalogueService;
    @RequestMapping("/showPage")
    public String showPage(HttpSession session){
        List<Diary> diaries = diaryService.queryDiaries();
        List<Chain> chains = chainService.queryChains();
        List<Catalogue> catalogues = catalogueService.showCatalogue();
        session.setAttribute("diaries",diaries);
        session.setAttribute("chains",chains);
        session.setAttribute("catalogues",catalogues);
        return "forward:/blog/showBlogs";
    }
}
